package com.FH.applyFrom.bespeak_service;
import com.FH.util.ResultDTO;
import javax.ejb.EJB;
import javax.enterprise.context.RequestScoped;
import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;

/**
 * Created by Administrator on 2016/12/13.
 */
@Path("/bespeakresourse")
@Produces(MediaType.APPLICATION_JSON)
@RequestScoped
public class BespeakResourse {
    @EJB
    private BespeakServiceDAO bespeakServiceDAO;

    /**
     * 按条件查询会员列表
     *
     * @param search
     * @param page
     * @param size
     * @return
     */
    @GET
    @Path("/{search}&{page}&{size}")
    public ResultDTO getBespeakServiceInfo(@PathParam("search") String search, @PathParam("page") String page, @PathParam("size") String size) {
        //添加分页查询
        if (null == page || "".equals(page) || "0".equals(page)) {
            page = "1";    //默认从第1页开始查起
        }/*else
        {
            page =((Integer.parseInt(page)-1)*Integer.parseInt(size))+"";
        }*/
        if (null == size || "".equals(size)) {
            size = "10";//默认10行数据
        }
        return bespeakServiceDAO.getBespeakServiceInfo(search, page, size);
    }

    @POST
    @Consumes(MediaType.APPLICATION_JSON)
    public ResultDTO addBespeakServiceInfo(BespeakServicePullDTO bespeakServicePullDTO) {
        return bespeakServiceDAO.addBespeakServiceInfo(bespeakServicePullDTO);
    }

    @PUT
    @Consumes(MediaType.APPLICATION_JSON)
    public ResultDTO deleteBespeakServiceInfo(BespeakServicePullDTO bespeakServicePullDTO) {

        return bespeakServiceDAO.deleteBespeakServiceInfo(bespeakServicePullDTO);
    }

    @PUT
    @Path("/update")
    @Consumes(MediaType.APPLICATION_JSON)
    public ResultDTO updateBespeakServiceInfo(BespeakServicePullDTO bespeakServicePullDTO) {
        return bespeakServiceDAO.updateBespeakServiceInfo(bespeakServicePullDTO);
    }


}
